package com.sskj.lib.util;

import android.app.Activity;
import android.text.TextUtils;

import com.alibaba.android.arouter.launcher.ARouter;
import com.sskj.common.base.App;
import com.sskj.common.util.ToastUtil;
import com.sskj.lib.R;
import com.sskj.lib.RConfig;
import com.sskj.lib.bean.UserData;

public class AppOuterCheckUtil {

    /**
     * 验证资金密码
     *
     * @param userData
     * @return
     */
    public static boolean checkTradePwd(Activity activity, UserData userData) {
        if (userData == null)
            return false;
        if (TextUtils.isEmpty(userData.getTpwd())) {
            TipUtil.getSureCancelTip(activity, App.INSTANCE.getString(R.string.lib_appDirectCheckUtil2_j), App.INSTANCE.getString(R.string.lib_appDirectCheckUtil8_j), App.INSTANCE.getString(R.string.lib_appDirectCheckUtil7_j), () -> {
                ARouter.getInstance().build(RConfig.MINE_SECURITY_CENTER).navigation();
            });
            return false;
        }
        return true;
    }

    /**
     * 验证支付方式
     *
     * @param userData
     * @return
     */
    public static boolean checkPayType(Activity activity, UserData userData) {
        if (userData == null)
            return false;
        if (TextUtils.isEmpty(userData.getPayment_type())) {
            TipUtil.getSureCancelTip(activity, App.INSTANCE.getString(R.string.lib_appDirectCheckUtil2_j), App.INSTANCE.getString(R.string.lib_appOuterCheckUtil4_j), App.INSTANCE.getString(R.string.lib_appDirectCheckUtil7_j), () -> {
                ARouter.getInstance().build(RConfig.MINE_PAYMENT).navigation();
            });
            return false;
        }
        return true;
    }


    /**
     * 验证高级实名认证
     * 1 未认证 2 待审核 3 已通过  4拒绝
     *
     * @param userData
     * @return
     */
    public static boolean checkHighAuth(Activity activity, UserData userData) {
        if (userData == null)
            return false;
//        if (!checkPayType(activity, userData)){
//            return false;
//        }
        if (userData.getAuth_status() == 1) {
            TipUtil.getSureCancelTip(activity, App.INSTANCE.getString(R.string.lib_appDirectCheckUtil2_j), App.INSTANCE.getString(R.string.lib_appOuterCheckUtil5_j), App.INSTANCE.getString(R.string.lib_appDirectCheckUtil7_j), () -> {
                ARouter.getInstance().build(RConfig.MINE_SECURITY_VERIFYHOME).navigation();
            });
            return false;
        }
        if (userData.getAuth_status() == 2) {
            ToastUtil.showShort(App.INSTANCE.getString(R.string.lib_appOuterCheckUtil6_j));
            return false;
        }
        if (userData.getAuth_status() == 4) {  // 拒绝
            TipUtil.getSureCancelTip(activity, App.INSTANCE.getString(R.string.lib_appDirectCheckUtil2_j), App.INSTANCE.getString(R.string.lib_appOuterCheckUtil5_j), App.INSTANCE.getString(R.string.lib_appDirectCheckUtil7_j), () -> {
                ARouter.getInstance().build(RConfig.MINE_SECURITY_VERIFYHOME).navigation();
            });
            return false;
        }
        return true;
    }

    /**
     * 验证商家
     *
     * @param userData
     * @return
     */
    public static boolean checkShop(Activity activity, UserData userData) {
        if (userData == null)
            return false;
        if (userData.getIs_shop().equals("false")) {  // 不是商家
            TipUtil.getSureCancelTip(activity, App.INSTANCE.getString(R.string.lib_appDirectCheckUtil2_j), App.INSTANCE.getString(R.string.lib_appOuterCheckUtil7_j), App.INSTANCE.getString(R.string.lib_appDirectCheckUtil4_j), () -> {
//                RxBus.getDefault().send(RxBusCode.CHECK);
                ARouter.getInstance().build(RConfig.MINE_SECURITY_CENTER).navigation();

            });
            return false;
        }
//        if (userData.getIs_shop().equals("2")) {  // 认证商家待审核
//            ToastUtil.showShort(App.INSTANCE.getString(R.string.lib_appOuterCheckUtil9_j));
//            return false;
//        }
//        if (userData.getIs_shop().equals("3")) {  // 解除商家待审核
//            ToastUtil.showShort(App.INSTANCE.getString(R.string.lib_appOuterCheckUtil9_j));
//            return false;
//        }
        return true;
    }
}
